﻿using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MyWebApp.Common.UIAttribute;
using MyWebApp.Common.Entity;
using MyWebApp.Models;

namespace MyWebApp.Common
{
    //指定session 只读
    [SessionState(System.Web.SessionState.SessionStateBehavior.ReadOnly)]
    public class BaseMvcController : Controller
    {
        private ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        protected LoginUserModel CurrentUser
        {
            get
            {
                return System.Web.HttpContext.Current.Session[Constant.CurrentUser] as LoginUserModel;
            }
            set
            {
                System.Web.HttpContext.Current.Session[Constant.CurrentUser] = value;
            }
        }

        protected string CurrentUserName
        {
            get {
                return CurrentUser == null ? "" : CurrentUser.UserName;
            }
        }
    }
}